$(function() {
var dtGridColumns = [{
    id : 'id',
    title : '序号',
    type : 'string',
    columnClass : 'text-center',
    headerStyle : 'color:grey;'
},{
    id : 'type',
    title : '部门',
    type : 'string',
    columnClass : 'text-center',
    headerStyle : 'color:grey;',
    resolution:function(value, record, column, grid, dataNo, columnNo){
    	if(record.depart == 1){
    		return "产业一部";
    	}
    	else if (record.depart ==2){
    		return "产业二部";
    	}
    	else{
    		return "产业三部";
    	}
    }
},{
    id : 'type',
    title : '分类',
    type : 'string',
    columnClass : 'text-center',
    headerStyle : 'color:grey;'
},{
    id : 'sort',
    title : '排序',
    type : 'string',
    columnClass : 'text-center',
    headerStyle : 'color:grey;'
},{
    id : 'operation',
    title : '操作',
    type : 'string',
    columnClass : 'text-center tpl-table-black-operation',
    headerStyle : 'color:grey;',
    resolution:function(value, record, column, grid, dataNo, columnNo){
        var content = '';
        content += '<a href="#" onclick="loadPage(\'type/'+record.id+'/select\');" shiro:hasPermission="type:edit"> <i class="am-icon-pencil"></i> 编辑</a> ';
        content += '  ';
        content += '<a href="#" onclick="delType('+record.id+');" class="tpl-table-black-operation-del del-btn" shiro:hasPermission="type:delete"><i class="am-icon-trash"></i> 删除</a>';
        return content;
    }
}];

var dtGridOption = {
	    lang : 'zh-cn',
	    ajaxLoad : true,
	    check : true,
	    checkWidth :'37px',
	    loadURL : 'type/list',
	    columns : dtGridColumns,
	    gridContainer : 'dtGridContainer',
	    toolbarContainer : 'dtGridToolBarContainer',
	    tools : '',
	    exportFileName : '分类表',
	    pageSize : 10,
	    pageSizeLimit : [10, 20, 30]
	};
	var grid = $.fn.dlshouwen.grid.init(dtGridOption);
	grid.load();
	$('select').selected();


});




function zTreeOnClick(event, treeId, treeNode) {
	console.log(treeNode.id);
	search(treeNode.id);
};

function delType(id){
	del("type/"+id+"/delete",search);
}


function btnDel(){
	var rows = grid.getCheckedRecords();
    if (rows.length == 1) {
 	   del('type/'+rows[0].id+'/delete',search);
    }else{
 	   layer.msg("你没有选择行或选择了多行数据", {
            icon : 0
        });
    }
}
function btnEdit(){
	   var rows = grid.getCheckedRecords();
    if (rows.length == 1) {
    	loadPage('type/'+rows[0].id+'/select');
    }else{
 	   layer.msg("你没有选择行或选择了多行数据", {
            icon : 0
        });
    }
}

